package com.engine.jucailinkq.common.util;

import com.google.gson.Gson;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ApiReturnTools {
    private static Gson gson = new Gson();

    public static String error(String errorCode,String errorMessage){
        Map<String,String> returnMap = new HashMap<>();
        returnMap.put("code",errorCode);
        returnMap.put("message",errorMessage);
        return gson.toJson(returnMap);
    }

    public static String success(Map<String,Object> dataMap){
        Map<String,Object> returnMap = new HashMap<>();
        returnMap.put("code","200");
        returnMap.put("data",dataMap);
        return gson.toJson(returnMap);
    }
    public static String success(List<Map<String,Object>> dataMap){
        Map<String,Object> returnMap = new HashMap<>();
        returnMap.put("code","200");
        returnMap.put("data",dataMap);
        return gson.toJson(returnMap);
    }
}
